import { Component, ComponentDecorator, Directive, ChangeDetectionStrategy } from '@angular/core';
import 'reflect-metadata';

const Platform = 'pc';

export function PlatformClassDistribute() {
    console.log('PlatformClassDistribute: evaluated');
    console.log(Platform);
    return function (constructor: Function) {
        if (Reflect.hasMetadata('annotations', constructor)) {
            console.log(Reflect.getMetadata('annotations', constructor));
        }
        console.log('PlatformClassDistribute: called');
        console.log(constructor);
    };
}


export function PlatformComponentWrapper(componentMetadata: any): Component {
    debugger;
    console.log(componentMetadata);
    if (componentMetadata && componentMetadata.templateUrl2) {
        const templateUrl = componentMetadata.templateUrl2;
        const pointHtml = templateUrl.lastIndexOf('.');
        const platformTemplateUrl = templateUrl.substring(0, pointHtml)
            + '.'
            + Platform
            + templateUrl.substring(pointHtml);

        componentMetadata.templateUrl = platformTemplateUrl;
    }
    console.log(componentMetadata);
    return componentMetadata;
}
